package com.meila.design.mode.observer;

import com.alibaba.fastjson.JSONObject;

import java.util.Observable;
import java.util.Observer;

/**
 * ***********************************************************
 *
 * @类名 : cms {MyObserver.java}
 * @DESCRIPTION : ===========XXXX==================
 * @AUTHOR :  meila-x->reese
 * @DATE : 2016/3/1
 * ***********************************************************
 */
public class MyObserver implements Observer {
    /**
     * This method is called whenever the observed object is changed. An
     * application calls an <tt>Observable</tt> object's
     * <code>notifyObservers</code> method to have all the object's
     * observers notified of the change.
     *
     * @param o   the observable object.
     * @param arg an argument passed to the <code>notifyObservers</code>
     */
    @Override
    public void update(Observable o, Object arg) {

        System.out.println("=========观察者模式监听开始...=============");
        System.out.println("====>"+ JSONObject.toJSONString(arg));
        System.out.println("====>"+JSONObject.toJSONString(o));
        System.out.println("====>监听结束end...");
    }
}
